﻿using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace WeaponEvalue.Logic
{
    public class SerializeHelpter <T>
    {
        public void  Serialize(object o, string fileName)
        {
            XmlSerializer xmlSerializer=new XmlSerializer(typeof(T));
            XmlTextWriter xmlTextWriter=new XmlTextWriter(fileName,Encoding.Default);
            xmlSerializer.Serialize(xmlTextWriter, o);   
        }

        public T DeSerialize(string fileName)
        {
            XmlSerializer xmlSerializer=new XmlSerializer(typeof(T));
            XmlTextReader xmlTextReader=new XmlTextReader(new StreamReader(fileName));
            return (T)xmlSerializer.Deserialize(xmlTextReader);
            
        }

    }
}